package cn.edu.scau.cmi.wujiaxian.exercise10;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;

public class XITI {
	public static void main(String[] args) {
		//1.FileInputStream
		//2.一个是读取字符数组，一个是读取字节数组
		//3.要用一个更低级的流封装（入FileReader）
		//4.对象需要序列化
		//5.使用对象流把对象加载到内存（用对象流包装数组流），然后取出来，就可以克隆一个对象。
		//6.先获取随机流的长度 - 1，再从尾read文件，直到文件头为止。
		//7.
		File file1 = new File("1.txt");
		File file2 = new File("2.txt");
 		try {
			BufferedReader in = new BufferedReader(
					new FileReader(file1));
 			BufferedWriter out  = new BufferedWriter(
					new FileWriter(file2));
			String s = null;
			while ((s = in.readLine()) != null) {
				out.write(s);
				out.newLine();
			}
			in.close();
			out.close();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
 		//8.
 		File file = new File("p.txt");
 		try {
			FileOutputStream out = new FileOutputStream(file);
			PrintStream p = new PrintStream(out);
			p.print(12345.6789);
			p.println("how are you");
			p.println(true);
			p.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
}
